package handlers

import (
	"context"

	pb "kitest1"
)

// NewService returns a naïve, stateless implementation of Service.
func NewService() pb.CalcServer {
	return calcService{}
}

type calcService struct{}

func (s calcService) Add(ctx context.Context, in *pb.CalcRequest) (*pb.CalcResponse, error) {
	var resp pb.CalcResponse
	resp.Result = in.A + in.B
	return &resp, nil
}

func (s calcService) Sub(ctx context.Context, in *pb.CalcRequest) (*pb.CalcResponse, error) {
	var resp pb.CalcResponse
	resp.Result = in.A - in.B
	return &resp, nil
}

func (s calcService) Mul(ctx context.Context, in *pb.CalcRequest) (*pb.CalcResponse, error) {
	var resp pb.CalcResponse
	resp.Result = in.A * in.B
	return &resp, nil
}

func (s calcService) Div(ctx context.Context, in *pb.CalcRequest) (*pb.CalcResponse, error) {
	var resp pb.CalcResponse
	resp.Result = in.A / in.B
	return &resp, nil
}

func (s calcService) HealCheck(ctx context.Context, in *pb.HealReQuest) (*pb.HealResponse, error) {
	var resp pb.HealResponse
	resp.Status = true
	return &resp, nil
}
